package thread;

import experiment.Array;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ArrayBlockingQueue;

/**
 * 阻塞队列
 * JUC:java.util.concurrent
 *     java.util.concurrent.atomic
 * ArrayBlockingQueue基于数列实现的阻塞队列
 * LinkedBlockingDeque基于链表实现的阻塞队列
 *
 */
public class Demo13 {
    public static void main(String[] args) throws InterruptedException {
        BlockingQueue queue = new ArrayBlockingQueue(3);
        queue.put(1);
        System.out.println("放数据1");
        queue.put(2);
        System.out.println("放数据2");
        queue.put(3);
        System.out.println("放数据3");
        queue.put(4);   //永远不会打印数据四，因为阻塞，只有放三个字符的大小
        System.out.println("放数据4");
    }
}
